package com.google.android.gms.internal;

import android.annotation.TargetApi;
import android.graphics.Bitmap;
import android.support.annotation.Nullable;
import android.support.v4.app.NotificationCompat;
import android.support.v4.internal.view.SupportMenu;
import android.support.v4.view.InputDeviceCompat;
import android.text.TextUtils;
import android.view.MotionEvent;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.android.gms.ads.internal.zzbt;
import com.google.android.gms.common.internal.Hide;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Hide
@zzabh
public final class zzanb extends FrameLayout implements zzamy {
    private final zzann zzdlg;
    private final FrameLayout zzdlh;
    private final zzov zzdli;
    private final zzanp zzdlj;
    private final long zzdlk;
    @Nullable
    private zzamz zzdll;
    private boolean zzdlm;
    private boolean zzdln;
    private boolean zzdlo;
    private boolean zzdlp;
    private long zzdlq;
    private long zzdlr;
    private String zzdls;
    private Bitmap zzdlt;
    private ImageView zzdlu;
    private boolean zzdlv;

    /* JADX WARNING: Illegal instructions before constructor call */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public zzanb(android.content.Context r11, com.google.android.gms.internal.zzann r12, int r13, boolean r14, com.google.android.gms.internal.zzov r15, com.google.android.gms.internal.zzanm r16) {
        /*
            r10 = this;
            r0 = r10
            r8 = r11
            r0.<init>(r8)
            r3 = r12
            r0.zzdlg = r3
            r6 = r15
            r0.zzdli = r6
            android.widget.FrameLayout r1 = new android.widget.FrameLayout
            r1.<init>(r8)
            r0.zzdlh = r1
            android.widget.FrameLayout r1 = r0.zzdlh
            android.widget.FrameLayout$LayoutParams r2 = new android.widget.FrameLayout$LayoutParams
            r9 = -1
            r2.<init>(r9, r9)
            r0.addView(r1, r2)
            com.google.android.gms.ads.internal.zzv r1 = r3.zzbo()
            com.google.android.gms.common.internal.zzc.zzv(r1)
            com.google.android.gms.ads.internal.zzv r1 = r3.zzbo()
            com.google.android.gms.internal.zzana r1 = r1.zzaol
            r2 = r8
            r4 = r13
            r5 = r14
            r7 = r16
            com.google.android.gms.internal.zzamz r1 = r1.zza(r2, r3, r4, r5, r6, r7)
            r0.zzdll = r1
            com.google.android.gms.internal.zzamz r1 = r0.zzdll
            if (r1 == 0) goto L_0x005c
            android.widget.FrameLayout r1 = r0.zzdlh
            com.google.android.gms.internal.zzamz r2 = r0.zzdll
            android.widget.FrameLayout$LayoutParams r3 = new android.widget.FrameLayout$LayoutParams
            r4 = 17
            r3.<init>(r9, r9, r4)
            r1.addView(r2, r3)
            com.google.android.gms.internal.zzny<java.lang.Boolean> r1 = com.google.android.gms.internal.zzoi.zzbmd
            com.google.android.gms.internal.zzog r2 = com.google.android.gms.internal.zzlc.zzio()
            java.lang.Object r1 = r2.zzd(r1)
            java.lang.Boolean r1 = (java.lang.Boolean) r1
            boolean r1 = r1.booleanValue()
            if (r1 == 0) goto L_0x005c
            r0.zzsx()
        L_0x005c:
            android.widget.ImageView r1 = new android.widget.ImageView
            r1.<init>(r8)
            r0.zzdlu = r1
            com.google.android.gms.internal.zzny<java.lang.Long> r1 = com.google.android.gms.internal.zzoi.zzbmh
            com.google.android.gms.internal.zzog r2 = com.google.android.gms.internal.zzlc.zzio()
            java.lang.Object r1 = r2.zzd(r1)
            java.lang.Long r1 = (java.lang.Long) r1
            long r1 = r1.longValue()
            r0.zzdlk = r1
            com.google.android.gms.internal.zzny<java.lang.Boolean> r1 = com.google.android.gms.internal.zzoi.zzbmf
            com.google.android.gms.internal.zzog r2 = com.google.android.gms.internal.zzlc.zzio()
            java.lang.Object r1 = r2.zzd(r1)
            java.lang.Boolean r1 = (java.lang.Boolean) r1
            boolean r1 = r1.booleanValue()
            r0.zzdlp = r1
            com.google.android.gms.internal.zzov r1 = r0.zzdli
            if (r1 == 0) goto L_0x009b
            com.google.android.gms.internal.zzov r1 = r0.zzdli
            java.lang.String r2 = "spinner_used"
            boolean r3 = r0.zzdlp
            if (r3 == 0) goto L_0x0096
            java.lang.String r3 = "1"
            goto L_0x0098
        L_0x0096:
            java.lang.String r3 = "0"
        L_0x0098:
            r1.zzf(r2, r3)
        L_0x009b:
            com.google.android.gms.internal.zzanp r1 = new com.google.android.gms.internal.zzanp
            r1.<init>(r0)
            r0.zzdlj = r1
            com.google.android.gms.internal.zzamz r1 = r0.zzdll
            if (r1 == 0) goto L_0x00ab
            com.google.android.gms.internal.zzamz r1 = r0.zzdll
            r1.zza(r0)
        L_0x00ab:
            com.google.android.gms.internal.zzamz r1 = r0.zzdll
            if (r1 != 0) goto L_0x00b6
            java.lang.String r1 = "AdVideoUnderlay Error"
            java.lang.String r2 = "Allocating player failed."
            r0.zzg(r1, r2)
        L_0x00b6:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.internal.zzanb.<init>(android.content.Context, com.google.android.gms.internal.zzann, int, boolean, com.google.android.gms.internal.zzov, com.google.android.gms.internal.zzanm):void");
    }

    public static void zza(zzann zzann) {
        HashMap hashMap = new HashMap();
        hashMap.put(NotificationCompat.CATEGORY_EVENT, "no_video_view");
        zzann.zza("onVideoEvent", hashMap);
    }

    public static void zza(zzann zzann, String str) {
        HashMap hashMap = new HashMap();
        hashMap.put(NotificationCompat.CATEGORY_EVENT, "decoderProps");
        hashMap.put("error", str);
        zzann.zza("onVideoEvent", hashMap);
    }

    public static void zza(zzann zzann, Map<String, List<Map<String, Object>>> map) {
        HashMap hashMap = new HashMap();
        hashMap.put(NotificationCompat.CATEGORY_EVENT, "decoderProps");
        hashMap.put("mimeTypes", map);
        zzann.zza("onVideoEvent", hashMap);
    }

    /* access modifiers changed from: private */
    public final void zza(String str, String... strArr) {
        HashMap hashMap = new HashMap();
        hashMap.put(NotificationCompat.CATEGORY_EVENT, str);
        String str2 = null;
        for (String str3 : strArr) {
            if (str2 == null) {
                str2 = str3;
            } else {
                hashMap.put(str2, str3);
                str2 = null;
            }
        }
        this.zzdlg.zza("onVideoEvent", hashMap);
    }

    private final boolean zzsz() {
        return this.zzdlu.getParent() != null;
    }

    private final void zzta() {
        if (this.zzdlg.zztj() != null && this.zzdln && !this.zzdlo) {
            this.zzdlg.zztj().getWindow().clearFlags(128);
            this.zzdln = false;
        }
    }

    public final void destroy() {
        this.zzdlj.pause();
        if (this.zzdll != null) {
            this.zzdll.stop();
        }
        zzta();
    }

    public final void onPaused() {
        zza("pause", new String[0]);
        zzta();
        this.zzdlm = false;
    }

    public final void pause() {
        if (this.zzdll != null) {
            this.zzdll.pause();
        }
    }

    public final void play() {
        if (this.zzdll != null) {
            this.zzdll.play();
        }
    }

    public final void seekTo(int i) {
        if (this.zzdll != null) {
            this.zzdll.seekTo(i);
        }
    }

    public final void zza(float f, float f2) {
        if (this.zzdll != null) {
            this.zzdll.zza(f, f2);
        }
    }

    public final void zzb(float f) {
        if (this.zzdll != null) {
            zzamz zzamz = this.zzdll;
            zzamz.zzdlf.zzb(f);
            zzamz.zzsn();
        }
    }

    public final void zzd(int i, int i2, int i3, int i4) {
        if (i3 != 0 && i4 != 0) {
            FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(i3, i4);
            layoutParams.setMargins(i, i2, 0, 0);
            this.zzdlh.setLayoutParams(layoutParams);
            requestLayout();
        }
    }

    public final void zzda(String str) {
        this.zzdls = str;
    }

    public final void zzf(int i, int i2) {
        if (this.zzdlp) {
            int max = Math.max(i / ((Integer) zzlc.zzio().zzd(zzoi.zzbmg)).intValue(), 1);
            int max2 = Math.max(i2 / ((Integer) zzlc.zzio().zzd(zzoi.zzbmg)).intValue(), 1);
            if (this.zzdlt == null || this.zzdlt.getWidth() != max || this.zzdlt.getHeight() != max2) {
                this.zzdlt = Bitmap.createBitmap(max, max2, Bitmap.Config.ARGB_8888);
                this.zzdlv = false;
            }
        }
    }

    @TargetApi(14)
    public final void zzf(MotionEvent motionEvent) {
        if (this.zzdll != null) {
            this.zzdll.dispatchTouchEvent(motionEvent);
        }
    }

    public final void zzg(String str, @Nullable String str2) {
        zza("error", "what", str, "extra", str2);
    }

    public final void zzso() {
        this.zzdlj.resume();
        zzaij.zzdfn.post(new zzanc(this));
    }

    public final void zzsp() {
        if (this.zzdll != null && this.zzdlr == 0) {
            zza("canplaythrough", "duration", String.valueOf(((float) this.zzdll.getDuration()) / 1000.0f), "videoWidth", String.valueOf(this.zzdll.getVideoWidth()), "videoHeight", String.valueOf(this.zzdll.getVideoHeight()));
        }
    }

    public final void zzsq() {
        if (this.zzdlg.zztj() != null && !this.zzdln) {
            this.zzdlo = (this.zzdlg.zztj().getWindow().getAttributes().flags & 128) != 0;
            if (!this.zzdlo) {
                this.zzdlg.zztj().getWindow().addFlags(128);
                this.zzdln = true;
            }
        }
        this.zzdlm = true;
    }

    public final void zzsr() {
        zza("ended", new String[0]);
        zzta();
    }

    public final void zzss() {
        if (this.zzdlv && this.zzdlt != null && !zzsz()) {
            this.zzdlu.setImageBitmap(this.zzdlt);
            this.zzdlu.invalidate();
            this.zzdlh.addView(this.zzdlu, new FrameLayout.LayoutParams(-1, -1));
            this.zzdlh.bringChildToFront(this.zzdlu);
        }
        this.zzdlj.pause();
        this.zzdlr = this.zzdlq;
        zzaij.zzdfn.post(new zzand(this));
    }

    public final void zzst() {
        if (this.zzdlm && zzsz()) {
            this.zzdlh.removeView(this.zzdlu);
        }
        if (this.zzdlt != null) {
            long elapsedRealtime = zzbt.zzes().elapsedRealtime();
            if (this.zzdll.getBitmap(this.zzdlt) != null) {
                this.zzdlv = true;
            }
            long elapsedRealtime2 = zzbt.zzes().elapsedRealtime() - elapsedRealtime;
            if (zzahw.zzqk()) {
                StringBuilder sb = new StringBuilder(46);
                sb.append("Spinner frame grab took ");
                sb.append(elapsedRealtime2);
                sb.append("ms");
                zzahw.v(sb.toString());
            }
            if (elapsedRealtime2 > this.zzdlk) {
                zzahw.zzcz("Spinner frame grab crossed jank threshold! Suspending spinner.");
                this.zzdlp = false;
                this.zzdlt = null;
                if (this.zzdli != null) {
                    this.zzdli.zzf("spinner_jank", Long.toString(elapsedRealtime2));
                }
            }
        }
    }

    public final void zzsu() {
        if (this.zzdll != null) {
            if (!TextUtils.isEmpty(this.zzdls)) {
                this.zzdll.setVideoPath(this.zzdls);
            } else {
                zza("no_src", new String[0]);
            }
        }
    }

    public final void zzsv() {
        if (this.zzdll != null) {
            zzamz zzamz = this.zzdll;
            zzamz.zzdlf.setMuted(true);
            zzamz.zzsn();
        }
    }

    public final void zzsw() {
        if (this.zzdll != null) {
            zzamz zzamz = this.zzdll;
            zzamz.zzdlf.setMuted(false);
            zzamz.zzsn();
        }
    }

    @TargetApi(14)
    public final void zzsx() {
        if (this.zzdll != null) {
            TextView textView = new TextView(this.zzdll.getContext());
            String valueOf = String.valueOf(this.zzdll.zzsj());
            textView.setText(valueOf.length() != 0 ? "AdMob - ".concat(valueOf) : new String("AdMob - "));
            textView.setTextColor(SupportMenu.CATEGORY_MASK);
            textView.setBackgroundColor(InputDeviceCompat.SOURCE_ANY);
            this.zzdlh.addView(textView, new FrameLayout.LayoutParams(-2, -2, 17));
            this.zzdlh.bringChildToFront(textView);
        }
    }

    /* access modifiers changed from: package-private */
    public final void zzsy() {
        if (this.zzdll != null) {
            long currentPosition = (long) this.zzdll.getCurrentPosition();
            if (this.zzdlq != currentPosition && currentPosition > 0) {
                zza("timeupdate", "time", String.valueOf(((float) currentPosition) / 1000.0f));
                this.zzdlq = currentPosition;
            }
        }
    }
}
